package com.warom.sdg.model;

/**
 * PLC设备实体类
 * 用于存储PLC设备信息
 */
public class PlcDeviceEntity {
    
    private int deviceId;        // 设备ID
    private String deviceName;   // 设备名称
    private String deviceIp;     // 设备IP地址
    private int devicePort;      // 设备端口号  
    private int unitId;          // Modbus从站地址
    private String protocol;     // 协议类型（TCP/RTU等）
    private boolean isActive;    // 设备是否活跃
    private String description;  // 设备描述
    private long lastConnectTime;// 最后连接时间
    private String deviceType;   // 设备类型（如：西门子S7-1200，三菱FX3U等）
    private int deviceTypeId;    // 设备类型ID，对应DeviceType枚举中的id
    private long createTime;     // 创建时间
    
    /**
     * 默认构造函数
     */
    public PlcDeviceEntity() {
    }
    
    /**
     * 带参数的构造函数
     */
    public PlcDeviceEntity(String deviceName, String deviceIp, int devicePort, int unitId, String protocol) {
        this.deviceName = deviceName;
        this.deviceIp = deviceIp;
        this.devicePort = devicePort;
        this.unitId = unitId;
        this.protocol = protocol;
        this.isActive = false;
        this.lastConnectTime = System.currentTimeMillis();
        this.createTime = System.currentTimeMillis();
    }
    
    /**
     * 带设备类型的构造函数
     */
    public PlcDeviceEntity(String deviceName, String deviceIp, int devicePort, int unitId, 
                          String protocol, String deviceType, int deviceTypeId) {
        this(deviceName, deviceIp, devicePort, unitId, protocol);
        this.deviceType = deviceType;
        this.deviceTypeId = deviceTypeId;
    }
    
    // Getters and Setters
    
    public int getDeviceId() {
        return deviceId;
    }
    
    public void setDeviceId(int deviceId) {
        this.deviceId = deviceId;
    }
    
    public String getDeviceName() {
        return deviceName;
    }
    
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    
    public String getDeviceIp() {
        return deviceIp;
    }
    
    public void setDeviceIp(String deviceIp) {
        this.deviceIp = deviceIp;
    }
    
    public int getDevicePort() {
        return devicePort;
    }
    
    public void setDevicePort(int devicePort) {
        this.devicePort = devicePort;
    }
    
    public int getUnitId() {
        return unitId;
    }
    
    public void setUnitId(int unitId) {
        this.unitId = unitId;
    }
    
    public String getProtocol() {
        return protocol;
    }
    
    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }
    
    public boolean isActive() {
        return isActive;
    }
    
    public void setActive(boolean active) {
        isActive = active;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public long getLastConnectTime() {
        return lastConnectTime;
    }
    
    public void setLastConnectTime(long lastConnectTime) {
        this.lastConnectTime = lastConnectTime;
    }
    
    public String getDeviceType() {
        return deviceType;
    }
    
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    
    public int getDeviceTypeId() {
        return deviceTypeId;
    }
    
    public void setDeviceTypeId(int deviceTypeId) {
        this.deviceTypeId = deviceTypeId;
    }
    
    public long getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }
    
    @Override
    public String toString() {
        return "PlcDeviceEntity{" +
                "deviceId=" + deviceId +
                ", deviceName='" + deviceName + '\'' +
                ", deviceIp='" + deviceIp + '\'' +
                ", devicePort=" + devicePort +
                ", unitId=" + unitId +
                ", protocol='" + protocol + '\'' +
                ", isActive=" + isActive +
                ", description='" + description + '\'' +
                ", lastConnectTime=" + lastConnectTime +
                ", deviceType='" + deviceType + '\'' +
                ", deviceTypeId=" + deviceTypeId +
                ", createTime=" + createTime +
                '}';
    }
} 